# @Time    :2025/4/7 19:50
"""
线程池
pool=concurrent.futures.ThreadPoolExecutor(max_workers=3)
pool.submit("当前线程执行的任务)

"""
import concurrent.futures


def func(tname):
    global word
    for i, char in enumerate(word):
        word[i] = chr(ord(char) ^ 1)
        print(f"{tname}: {word}\n", end="")
    return word


if __name__ == "__main__":
    word = list("idmmn!vnsme")
    # 使用with语句来确保线程被迅速清理
    with concurrent.futures.ThreadPoolExecutor(max_workers=3) as executor:
        future1 = executor.submit(func, "线程1")
        future2 = executor.submit(func, "线程2")
        future3 = executor.submit(func, "线程3")
        word = future1.result()
        word = future2.result()
        word = future3.result()
        print("".join((word)))
